package miningMindsUtil;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

import functions.TermFunction;

public class ExportLabelResultFB_CT {
	public static void main(String args[]){
		String path_fb = "D:\\Development\\DATA\\Naver News\\LabelResultFB_TC.txt";
		String path_tw = "D:\\Development\\DATA\\Naver News\\LabelResult_TC.txt";
		
		String path_fb_tc = "D:\\Development\\DATA\\Naver News\\TermCounts_FB.txt";
		String path_tw_tc = "D:\\Development\\DATA\\Naver News\\TermCounts_TW.txt";
		
		try{
			FileReader fr = new FileReader(path_tw);
			BufferedReader br = new BufferedReader(fr);

			FileWriter fw = new FileWriter(new File(path_tw_tc));
			BufferedWriter bw = new BufferedWriter(fw);

			String line = "";
			Boolean isFst = true;
			Boolean isUID = false;
			String userID;
			
			while(true){
				line = br.readLine();
				if( line == null ){
					if(isUID){
						// Add previous data 
					}
					break;
				}
				if( line.startsWith("// UserID")  ){
					isUID = true;
					if( isFst ){
						isFst = false;
					}else{
					} // Add previous data
					
					
					userID = line.substring(11);
					
				}else{
					StringTokenizer st = new StringTokenizer(line,"\t");
					
					int stcount = st.countTokens();
					if(stcount == 8){
						
						
						String tokenid = st.nextToken();
						String token = st.nextToken();
						String msg = token.replaceAll("[\\s]", " ");
	
						String t_time = st.nextToken();
						String t_category1 = st.nextToken().replaceAll("/", "").replaceAll(" ", "");
						String t_category2 = st.nextToken().replaceAll("/", "").replaceAll(" ", "");
						String t_category3 = st.nextToken().replaceAll("/", "").replaceAll(" ", "");
						String t_category4 = st.nextToken().replaceAll("/", "").replaceAll(" ", "");
	
						String msg_exp = st.nextToken();
						bw.write(tokenid + "\t" + msg_exp);
						bw.newLine();
					
						
						
					}//end of stcount IF

				}

			}
			
			br.close();
			fr.close();
			
			bw.close();
			fw.close();
			
			
		}catch(Exception e){
			e.printStackTrace();
		}
		
	}
}
